/**
 *
 */
package de.cbf.cam.dsa.facet.talent.persister.db4o.client;

import java.util.Map;

import org.eclipse.jface.preference.IPreferenceStore;

import de.cbf.cam.dsa.facet.talent.FacetTalent;
import de.cbf.cam.dsa.facet.talent.persister.db4o.client.act.ActivatorFacetTalent_Db4oClient;
import de.cbf.cam.dsa.facet.talent.service.persister_interface.IServicePersister_FacetTalent;
import de.cbf.util.db.interfaces.exceptions.EntityLoadException;
import de.cbf.util.db.interfaces.exceptions.EntitySaveException;
import de.cbf.util.entity.facet.persistence.db4o.AbstractReflectiveElementPersisterDB4O;
import de.cbf.util.uuidheader.entities.UUIDReference;
import de.cbf.util.uuidheader.interfaces.IUUIDHeader;

/**
 * @author Nebelritter * 
 */
public class ServicePersister_FacetTalent_Db4o extends AbstractReflectiveElementPersisterDB4O implements IServicePersister_FacetTalent{

	public static final String NAME = "Facet:Talent:DB4O";
	
	/* (non-Javadoc)
	 * @see de.cbf.util.entity.facet.persistence.db4o.AbstractReflectiveElementPersisterDB4O#init()
	 */
	@Override
	protected void init() {		
		super.init();
		setDisplayName(NAME);
	}
	
	@Override
	protected IPreferenceStore getPreferenceStoreFromActivator() {
		return ActivatorFacetTalent_Db4oClient.getDefault().getPreferenceStore();
	}
	
	@Override
	protected Class<? extends IUUIDHeader> getPersistedClass() {
		return FacetTalent.class;
	}

	@Override
	public void persistFacetTalent(FacetTalent facet,Map<String, Object> options) throws EntitySaveException {
		persistElement(facet,options);		
	}

	@Override
	public FacetTalent loadFacetTalent(UUIDReference reference) throws EntityLoadException {
		IUUIDHeader element = loadElement(reference);		
		if (element instanceof FacetTalent) {
			FacetTalent facetTalent = (FacetTalent) element;
			return facetTalent;
		}
		throw new EntityLoadException("entity of wrong type(expected "+FacetTalent.class.getSimpleName()+"): "
				+element==null?"null":element.getClass().getSimpleName());		
	}

	
}
